package com.zzyl.job;

import com.zzyl.dto.AlertNotifyDto;
import com.zzyl.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.time.LocalDateTime;
import java.util.List;

@Component
public class MyTask {

//    @Scheduled(fixedRate = 2000) //固定速率，每隔2秒执行一次方法
//    @Scheduled(cron = "0 1-30 * * * ?")
//    public void task(){
//        System.out.println(LocalDateTime.now());
//    }

@Autowired
WebSocketServer webSocketServer;
//   @Scheduled(fixedRate = 2000) //固定速率，每隔2秒执行一次方法
    public void task() throws IOException {
        System.out.println(LocalDateTime.now());
//       webSocketServer.sendMessageToAll("wo shi yangeit");

       AlertNotifyDto alertNotifyDto = new AlertNotifyDto();
       alertNotifyDto.setNotifyType(1);
       alertNotifyDto.setVoiceNotifyStatus(1);
       alertNotifyDto.setAlertDataType(1);
       List<Long> userIds = List.of(1671403256519078138L);


       webSocketServer.sendMessageToConsumer(alertNotifyDto,userIds);

    }
}
